Results 1 to 2 of 2

Thread: Authors - MSWord file split

  1. #1
    Inactive Member sasha17's Avatar
    Join Date
    November 9th, 2010
    Posts
    30
    Follows
    0
    Following
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quoted
    0 Post(s)

    Authors - MSWord file split

    ***copied & pasted directly from the forum***

    Here's a macro I found online that actually does what it's supposed to do. It splits a large Word document into separate files, so if you're posting a story (for example) to a forum that has character limits, you can split a document into smaller Word files without losing anything.*

    Here's the macro code:

    '-------------Begin-----------------
    Sub doc_splitter()
    ' Copyright by W. Polmann
    ' Use at your own risk

    origdoc = ActiveDocument.Name

    Dim Mldg, Titel, Voreinstellung, Batches
    Mldg = "Number of batches?"
    Titel = "Freeware by www.ecm-e.de, W. Polmann."
    Voreinstellung = "1" ' Voreinstellung festlegen.
    ' Meldung, Titel und Standardwert anzeigen.
    Batches = InputBox(Mldg, Titel, Voreinstellung)

    Prozentsprung = 100 / Batches

    For x = 1 To Batches


    ActiveDocument.SaveAs FileName:="Teil_" & x & "_" & origdoc & ".doc", _
    FileFormat:=wdFormatDocument, LockComments:=False, Password:="", _
    AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, _
    EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData _
    :=False, SaveAsAOCELetter:=False


    EndeProzentsprung = Prozentsprung * x
    AnfangProzentsprung = EndeProzentsprung - Prozentsprung


    Selection.GoTo What:=wdGoToPercent, Which:=wdGoToNext, Count:=AnfangProzentsprung, Name:=""
    Anfang = Selection.Start

    Selection.GoTo What:=wdGoToPercent, Which:=wdGoToNext, Count:=EndeProzentsprung, Name:=""
    ' Bis zur n?chsten Absatzmarke hoch


    Selection.Find.ClearFormatting
    With Selection.Find
    .text = "^p"
    .Replacement.text = ""
    .Forward = True
    .Wrap = wdFindAsk
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    End With
    Selection.Find.Execute
    Selection.MoveRight Unit:=wdCharacter, Count:=1
    Ende = Selection.End


    Set Range = ActiveDocument.Range(Anfang, Ende)


    Range.Select
    Selection.Copy


    Selection.WholeStory
    Selection.Delete Unit:=wdCharacter, Count:=1
    Selection.Paste
    ActiveDocument.Save
    ActiveDocument.Close

    Documents.Open FileName:=origdoc, _
    ConfirmConversions:=False, ReadOnly:=False, AddToRecentFiles:=False, _
    PasswordDocument:="", PasswordTemplate:="", Revert:=False, _
    WritePasswordDocument:="", WritePasswordTemplate:="", Format:= _
    wdOpenFormatAuto

    Next x

    ActiveDocument.Close

    End Sub
    '---------End---------------

    Notes:
    • [li]To add a macro to Word 2007, u MUST have the 'Developer' tab showing in the ribbon. Add that thru the Word Options panel.[/li]
      [li]In Word 2007, I had to delete the '--------End------ comment.[/li]
      [li]The macro will ask u how many parts to make.[/li]
      [li]The macro will rename your files, adding a 'Teil_x_originalfilename.docx.doc' format, but ur original document will remain intact.[/li]
      [li]Use a BackUp copy![/li]
      [li]Just open the file, and run the macro.[/li]


    * I didn't 'lose' anything, but some of u aren't me.
    [url]http://theotherfreecatfights.com[/url]

  2. #2
    Senior Hostboard Member Catwacher's Avatar
    Join Date
    November 30th, 2002
    Posts
    224
    Follows
    0
    Following
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quoted
    0 Post(s)

    Re: Authors - MSWord file split

    Thanks sweetheart! :-)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •